$(function(){
    sessionStorage.clear();
     //登录
    $("#login_btn").click(function(){
        var phone=$("#phone").val();
        var pwd=$("#pwd").val();
        var reg=/^(\+86|0086)?\s*1[34578]\d{9}$/;
	if(!reg.test(phone)){
            alert("手机号码格式不正确");
            return false;
        }
         if(!pwd){
             alert("密码不能为空");
             return false;
        }
        var d={};
        d.username=phone;
        d.password=pwd;
        d.method="login";
        $.ajax({
            type:"post",
            async:true, 
            url:"http://www.rice.com/app/api/h5_access",
            data:d,
            dataType:"json",
            success:function(result){
//                console.log(1);
                if(result.status=="1"){
//                    console.log(result.message);
                    var data=result.data;
                    sessionStorage.setItem("token",data.token);
                    location.href="home.html";
                }else if(result.status=="2"){
                    alert(result.message);
                    location.href="login.html";
                }else{
                    alert(result.message);
                }
               
            }
        })
    })
})